﻿<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output media-type="text/plain" method="text" indent="yes" encoding="utf-8" />
  <xsl:template match="/">
    <xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">]]></xsl:text>
    <html>
      <head>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta charset="utf-8">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">]]></xsl:text>

        <title>Type Listing</title>

        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="description" content="">]]></xsl:text>
        <xsl:text disable-output-escaping="yes"><![CDATA[<meta name="viewport" content="width=device-width">]]></xsl:text>

        <style type="text/css">
          <xsl:comment>Styles here </xsl:comment>
        </style>

      </head>
      <body>
        <xsl:apply-templates select="TypeListing" />

        <xsl:text disable-output-escaping="yes"><![CDATA[<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>]]></xsl:text>

        <xsl:comment>Local Javascript here </xsl:comment>
        <xsl:text disable-output-escaping="yes"><![CDATA[<script>
		$(document).ready(function() {

			$('tr:even').addClass('even');
			
			$('a.toggle').click(function() {

				var table = $(this).parent().parent().next();

				var newPrompt = '';

				if (table.is(':hidden')) {
					newPrompt = 'Hide';
				} else {
					newPrompt = 'Show';
				}

				table.slideToggle();
				$(this).text(newPrompt);
				
				return false;
			});
		});

	</script>]]></xsl:text>

      </body>
    </html>

  </xsl:template>

  <xsl:template match="TypeListing">
    <header>
      <hgroup>
        <h1>
          <xsl:value-of select="@Name" />
        </h1>
      </hgroup>

      <xsl:call-template name="navigation" />
    </header>

    <xsl:apply-templates select="Namespaces" />

    <footer>
      <xsl:call-template name="navigation" />
      <p>
        Generated by
        <a>
          <xsl:attribute name="href">
            <xsl:value-of select="@ProductLink" />
          </xsl:attribute>
          <xsl:value-of select="@ProductName" /> version <xsl:value-of select="@ProductVersion" />
        </a>
      </p>
    </footer>

  </xsl:template>


  <!-- Top level changes -->

  <xsl:template match="Namespaces">

    <xsl:apply-templates select="Namespace" />

  </xsl:template>

  <xsl:template match="Namespace">
    <article>
      <header>
        <h2><xsl:value-of select="@Name" /></h2>
      </header>
      
      <xsl:apply-templates select="Types" />
    </article>
  </xsl:template>

  <xsl:template match="Types">
    <table summary="List of types">
      <caption>Types</caption>
      <tbody>
        <xsl:for-each select="Type">
          <tr><td><xsl:value-of select="@Name" /></td></tr>
        </xsl:for-each>
      </tbody>
    </table>  
  </xsl:template>

  <xsl:template name="navigation">
    <nav>
      <ul>
        <li>
          <a>
            <xsl:attribute name="href">
              <xsl:value-of select="@SummaryName" />.html
            </xsl:attribute>Summary
          </a>
        </li>
      </ul>
    </nav>
  </xsl:template>

</xsl:stylesheet>
